package torinoflickrdata.db;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.gps.utils.LatLonPoint;

public class Main2FlickrData {

	public static void main (String [] args) throws Exception{
		//continene tutti gli utenti  
		List<FlickrUser> f = new ArrayList<FlickrUser>();
		FlickrUserMethods.loadFlickrUser2(f, "TO_bbox/FlickrUsers3EventsSortedTS2106-3107Noduplicates.csv");
		
		Collections.sort(f);
		
		for (int i = 0; i < f.size(); i++) {
			System.out.println(f.get(i).toString());
		}
	    Map<FlickrUser, List<PLSUser>> data = null;
		List<PLSUser> pls_user ;
		for (int i = 0; i < f.size(); i++) {
			System.out.println(f.get(i).username);
		}
		Collections.sort(f);
		//FlickrUserMethods.printUserTsAndCoord("FlickrUsersTsAndCoord.csv", f);
		data = new HashMap<FlickrUser, List<PLSUser>>();
		for (int i = 0; i < f.size(); i++) {	
		
			pls_user = new ArrayList<PLSUser>();
			if((f.size() -(i+1))==0){
				break;
			}
			String username_i1 = f.get(i+1).username;
			String username_i = f.get(i).username;
			
			System.out.println(username_i);
			
				double fl_lat = f.get(i).lat;
				double fl_lon = f.get(i).lon;
				
				System.out.println("***********"+fl_lat+", "+fl_lon);
				long ts_flickr_user = f.get(i).timest;
				pls_user = new ArrayList<PLSUser>();
				System.out.println("****** "+f.get(i).username+" ha timestamp = "+ts_flickr_user);
				pls_user = FlickrUserMethods.ts_pls_list4FlickrUser("C:\\Users\\Alket\\codeindigo\\FlickrAPI\\AllData",
						fl_lat, fl_lon, ts_flickr_user);
				
				data.put(f.get(i), pls_user);
				
				if(!(username_i.equals(username_i1))){
				FlickrUserMethods.print("Flickr2PLSResults4Test1_"+username_i+", "+i+"_10min.txt", data);
				data = new HashMap<FlickrUser, List<PLSUser>>();
				}
			}
				
	    
	    
    }
}